var app = getApp();

Page({
  data: {
    // showFlag: !1,
    showFlag: 1
  },
  switch1Change: function (a) {
    var that = this
    var my_id = that.data.my_id
    if (a.detail.value == false) {
      var mydatype = 0
    }
    if (a.detail.value == true) {
      var mydatype = 1
    }
    app.util.request({
      'url': 'entry/wxapp/Myswitch1Change',
      data: {
        my_id: my_id,
        mydatype: mydatype,
        op: 'post'
      },
      success: function (res) {
        console.log(res)
        a.detail.value ? that.setData({
          flag: 1
        }) : that.setData({
          flag: 0
        });
      }
    })
  },
  onLoad: function (a) {
    var e = this;
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
    var my_id = a.my_id
    this.setData({
      my_id: my_id,
    })
  },
  onReady: function () {
    this.getMyswitch1Change()
  },
  getMyswitch1Change: function () {
    var that = this
    var my_id = that.data.my_id
    console.log(my_id)
    app.util.request({
      'url': 'entry/wxapp/Myswitch1Change',
      data: {
        my_id: my_id,
        op: 'display'
      },
      success: function (res) {
        console.log(res.data.mydatype)
        if (res.data.mydatype == 0) {
          that.setData({
            authStateBoo: false
          })
        }
        if (res.data.mydatype == 1) {
          that.setData({
            authStateBoo: true
          })
        }
      }
    })
  }
});